<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>

<html>
<head>
    <title>登录页</title>
    <%--echart线图、柱状图、饼图等各种图型库 cdn--%>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
    <%--jquery cdn--%>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
</head>
<body>


<form action="/list.do">
    姓名/工号 <input name="nameOrNum" value="${query.nameOrNum}"><br>
    部门 <select name="deptId">
    <option value="">请选择</option>
    <c:forEach items="${deptList}" var="d">
        <option     ${query.deptId == d.id ? 'selected':''} value="${d.id}">${d.name}</option>
    </c:forEach>
</select><br>

    小组 <select name="groupId">
    <option value="">请选择</option>
    <c:forEach items="${groupList}" var="g">
        <option   ${query.groupId == g.id ? 'selected':''} value="${g.id}">${g.name}</option>
    </c:forEach>

</select><br>
    是否考勤 <select name="kaoqin">
    <option value="">请选择</option>
    <option   ${query.kaoqin==1 ? 'selected' : ''} value="1">是</option>
    <option   ${query.kaoqin==0 ? 'selected' : ''} value="0">否</option>
</select><br>

    入职日期 <input type="date" name="createTimeStart" value="${query.createTimeStart}"> <input type="date"
                                                                                            name="createTimeEnd"
                                                                                            value="${query.createTimeEnd}"><br>

    <input type="submit" value="查询">
    <input type="button"  onclick="batchDel()" value="批量删除">


    <table>
        <tr>
            <td></td>
            <td>id</td>
            <td>工号</td>
            <td>姓名</td>
            <td>性别</td>
            <td>生日</td>
            <td>部门</td>
            <td>分组</td>
            <td>考勤</td>
            <td>入职日期</td>
            <td>状态</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pageInfo.list}" var="e">
            <tr>
                <td><input type="checkbox" name="delId" value="${e.id}"></td>
                <td>${e.id}</td>
                <td>${e.num}</td>
                <td>${e.name}</td>
                <td>${e.sex == 1 ? '男':'女'}</td>
                <td>${e.birthday}</td>
                <td>${e.deptName}</td>
                <td>${e.groupName}</td>
                <td>${e.kaoqin == 1 ?'是':'否'}</td>
                <td>${e.createTime}</td>
                <td>${e.status}</td>
                <td><a href="/del.do?id=${e.id}">删除</a></td>
            </tr>
        </c:forEach>

        <tr>
            <td>
                <button name="pageNum" value="1">首页</button>
                <button name="pageNum" value="${pageInfo.prePage}">上页</button>
                <button name="pageNum" value="${pageInfo.nextPage}">下页</button>
                <button name="pageNum" value="${pageInfo.pages}">尾页</button>
            </td>
        </tr>
    </table>
</form>


</body>
<script>

    function batchDel() {
        var id = [];

        $('[name=delId]:checked').each(function (){
            let value = this.value;
            console.log(value)
            id.push(value)
        })
        if (id.length ==0){
            alert("至少选择一条数据")
            return;
        }

        location.href='/del.do?id=' + id
    }
</script>
</html>